package matriceGene;

import exceptionGene.IndiceIncorrectException;
import exceptionGene.MauvaiseDimensionException;
import exceptionGene.FonctionObjectifDejaParametreeException;



public class TestMatriceGene {
	public static void main(String args[]) {
		//Resulat correct : 0.0  50.0  9.0  0.0  0.0
		Simplexe simplex = new Simplexe(2);

		try {
			Equation eq1 = new Equation(2, false, Equation.INF_OU_EGAL);
			eq1.setCoefficient(0, 4f);
			eq1.setCoefficient(1, -3f);
			eq1.setPartieDroite(9f);
			simplex.ajouterEquation(eq1);
			
			Equation eq2 = new Equation(2, false, Equation.INF_OU_EGAL);
			eq2.setCoefficient(0, 3f);
			eq2.setCoefficient(1, 2f);
			eq2.setPartieDroite(100f);
			simplex.ajouterEquation(eq2);
			
			Equation fctObj = new Equation(2, true, Equation.INF_OU_EGAL);
			fctObj.setMaximiser(true);
			fctObj.setCoefficient(0, 10f);
			fctObj.setCoefficient(1, 12f);
			simplex.ajouterEquation(fctObj);
		} catch (FonctionObjectifDejaParametreeException e) {
			e.printStackTrace();
		} catch (MauvaiseDimensionException e) {
			e.printStackTrace();
		} catch (IndiceIncorrectException e) {
			e.printStackTrace();
		}
		
		try {
			simplex.setNomVariable(0, "x");
			simplex.setNomVariable(1, "y");
		} catch (IndiceIncorrectException e1) {
			e1.printStackTrace();
		}
		
		simplex.resoudre();
		
		System.out.println("Matrice augmentee : \n");
		System.out.println(simplex.afficheMatriceAugmentee());
		System.out.println("Historique : \n");
		System.out.println(simplex.imprimeHistorique());
		System.out.println("Solution basique "+simplex.afficheSolutionBaseRealisableCourante());
		try {
			System.out.println(simplex.getPhraseExplicativeEtape(-1));
			for (int i = 0; i < simplex.getnombreDeMatrices(); i++) {
				System.out.println(simplex.getPhraseExplicativeEtape(i));
			}
			
			for(int i = 0; i < simplex.getNbSolutionBaseRealisable(); i++) {
				System.out.println(simplex.afficheSolutionBaseRealisableEtape(i));
			}
		} catch (IndiceIncorrectException e) {
			e.printStackTrace();
		}
	}
}
